﻿using Futaba.SBus.Telemetry.Configuration;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace Futaba.SBus.Telemetry
{
	/// <summary>
	/// The specification of a slot, which resembles a <see cref="SensorParameter"/>'s
	/// value in an S.BUS stream
	/// </summary>
	public interface ISlot : INotifyPropertyChanged
	{
		/// <summary>
		/// The sensor which provides this slot
		/// (ignored during serialization)
		/// </summary>
		Sensor Sensor { get; set; }
		/// <summary>
		/// The <see cref="Configuration.Sensor.SensorType"/> of this slot
		/// (serialized instead of <see cref="ISlot.Sensor"/>)
		/// </summary>
		SensorType SensorType { get; set; }
		/// <summary>
		/// The actual slot (position within the S.BUS stream) 
		/// </summary>
		SlotIdType SlotId { get; set; }
		/// <summary>
		/// The sequence of the <see cref="CurrentValue"/> (not serialized)
		/// </summary>
		/// <remarks>
		/// Futaba protocol seems to cycle sequence bytes for every couple of packets, but
		/// all <see cref="SlotId">slots</see> with the same Sequence were received in the same packet
		/// </remarks>
		byte Sequence { get; set; }
		/// <summary>
		/// The multiplies of the transported value for this instance. This can be different
		/// for the different <see cref="SensorParameter"/> instances declared in a S.BUS stream
		/// </summary>
		/// <remarks>
		/// When using multiple RPM sensors, for example, a magnetic sensor usually has a different
		/// ratio to an optical sensor, or if you want to account for a gear-ratio
		/// </remarks>
		double ValueMultiplyer { get; set; }
		/// <summary>
		/// The slot's display name (ie. Rotor-RPM, Turbine-RPM, etc.)
		/// </summary>
		string DisplayName { get; set; }
		/// <summary>
		/// The <see cref="SensorParameter.ParameterName"/> of this slot
		/// (serialized instead of <see cref="ISlot.Parameter"/>)
		/// </summary>
		string ParameterName { get; set; }
		/// <summary>
		/// The parameter provides additional parsing and displaying context for this slot
		/// (ignored during serialization)
		/// </summary>
		SensorParameter Parameter { get; set; }
		/// <summary>
		/// The slot's current/last value
		/// </summary>
		/// <seealso cref="ReceivedUtc"/>
		double? CurrentValue { get; set; }
		/// <summary>
		/// The date/time (UTC) the <see cref="CurrentValue"/> was last received
		/// (even if the value has not changed)
		/// </summary>
		DateTime ReceivedUtc { get; set; }
		/// <summary>
		/// A context used by the <see cref="SlotValueParser"/> for internal purposes
		/// </summary>
		SlotValueParserContext ParseContext { get; }
	}
}
